/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util.observer;

/**
 * mutable object state
 * synchronized for threading
 * @author martin
 */
public class Flag<T> implements Trigger<Boolean> {
  private boolean _state;
  private final T _trigger;
  
  public Flag(final T trigger){
    _state=false;
    _trigger=trigger;
  }
  
  public synchronized boolean isActive(){
    return _state;
  }

  @Override
  public synchronized void poke(Boolean par0) {
    _state=par0;
  }

  @Override
  public boolean equals(Object o){
    return _trigger.equals(o);
  }
  
  @Override
  public int hashCode(){
    return _trigger.hashCode();
  }
  
  @Override
  public String toString(){
    return "state("+_trigger.toString()+")";
  }
}
